/*jslint node:true*/
'use strict';
var events = require('events');
var eventEmitter = new events.EventEmitter();

var listener1 = function listener1() {
    console.log('listener1 act');
};
var listener2 = function listener2() {
    console.log('listener2 act');
};

eventEmitter.addListener('connection', listener1);
eventEmitter.on('connection', listener2);

var listenerCount = events.EventEmitter.listenerCount(eventEmitter, 'connection');
console.log(listenerCount + ' listeners listens on connection event');

eventEmitter.emit('connection');

eventEmitter.removeListener('connection', listener1);
console.log('remove listener1');

listenerCount = events.EventEmitter.listenerCount(eventEmitter, 'connection');
console.log(listenerCount + ' listeners listens on connection event');

eventEmitter.emit('connection');

console.log('程序执行完毕');